import { defineStore } from 'pinia'
import { getPlayerPage, savePlayer, getPlayerPoints, setPlayerPoints } from '../api/player'

export const usePlayerStore = defineStore('player', {
  state: () => ({
  }),
  actions: {
    getPlayerPage(params: any): Promise<any> {
      return new Promise((resolve, reject) => {
        getPlayerPage(params)
          .then((res:any) =>{
            resolve(res)
          })
          .catch(err => reject(err))
      })
    },
    savePlayer(params: any): Promise<any> {
      return new Promise((resolve, reject) => {
        savePlayer(params)
          .then((res:any) =>{
            resolve(res)
          })
          .catch(err => reject(err))
      })
    },
    getPlayerPoints(params: any): Promise<any> {
      return new Promise((resolve, reject) => {
        getPlayerPoints(params)
          .then((res:any) =>{
            resolve(res)
          })
          .catch(err => reject(err))
      })
    },
    setPlayerPoints(params: any): Promise<any> {
      return new Promise((resolve, reject) => {
        setPlayerPoints(params)
          .then((res:any) =>{
            resolve(res)
          })
          .catch(err => reject(err))
      })
    },
  },
})